#!/bin/bash
set -e

if [[ -n "${RF_DEBUG}" ]]; then
    set -x
fi

function usage() {
    echo -n \
        "Usage: $(basename "$0")

Update project dependencies, build assembly JARs, run database migrations.
"
}

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
    if [ "${1:-}" = "--help" ]; then
        usage
    else
        echo "Building Scala assembly JARs"
        ./sbt \
            ";api/assembly;backsplash-server/assembly;batch/assembly"

        echo "Running application database migrations"
        ./scripts/migrate migrate
    fi
fi
